package com.wiloon.androidx.dao;

import android.content.Context;

import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.wiloon.androidx.entity.Foo;

import java.sql.SQLException;

/**
 * Created by wiloon on 7/25/14.
 */
public class FooDaoImpl implements FooDao {
    private Dao<Foo, Integer> dao = null;
    private Context context;
    private OrmLiteSqliteOpenHelper helper;

    public FooDaoImpl(Context context) {
        this.context = context;
        helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
        try {
            dao = helper.getDao(Foo.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void finalize() throws Throwable {
        OpenHelperManager.releaseHelper();
        super.finalize();
    }
}
